package homework.hoomework_10.phone;

import java.util.Scanner;

/**
 * @author 朱
 * @date 2019042221:47
 */
public class PhoneTest {
    static Scanner scannerString=new Scanner(System.in);
    static Scanner scannerInt=new Scanner(System.in);
    static PhoneDao phoneDaoSet=new PhoneDaoSet();
    static PhoneDao phoneDaoHashMap=new PhoneDaoHashMap();
    static PhoneDao phoneDaoIO=new PhoneDaoIO();
    public static void main(String[] args) {
        while (true){
            System.out.println("----手机管理系统----");
            System.out.println("1.入库");
            System.out.println("2.根据型号查询");
            System.out.println("3.根据名称查询");
            System.out.println("4.查询所有");
            System.out.println("5.出库");
            System.out.println("6.退出");
            System.out.println("请输入您的选择：");
            int chese=scannerInt.nextInt();
            switch (chese){
                case 1:
                    stock();
                    break;
                case 2:
                    select_type();
                    break;
                case 3:
                    select_name();
                    break;
                case 4:
                    selectAll();
                    break;
                case 5:
                    delete();
                    break;
                case 6:
                    System.out.println("退出系统成功!");
                    System.exit(0);
                    break;
                default:
                    System.out.println("输入错误，请重新输入!");
                    break;
            }
        }
    }

    private static void stock() {
        System.out.println("----手机入库----");
        System.out.println("请输入手机型号：");
        String type=scannerString.nextLine();
        System.out.println("请输入手机名称：");
        String name=scannerString.nextLine();
        System.out.println("请输入手机颜色：");
        String color=scannerString.nextLine();
        Phone phone=new Phone(type,name,color);
//        phoneDaoSet.stock(phone);
//        phoneDaoHashMap.stock(phone);
        phoneDaoIO.stock(phone);
    }

    private static void select_type() {
        System.out.println("----型号查找手机----");
        System.out.println("请输入手机型号：");
        String type=scannerString.nextLine();
//        phoneDaoSet.select_type(type);
//        phoneDaoHashMap.select_type(type);
        phoneDaoIO.select_type(type);
    }

    private static void select_name() {
        System.out.println("----名称查找手机----");
        System.out.println("请输入手机名称：");
        String name=scannerString.nextLine();
//        phoneDaoSet.select_name(name);
//        phoneDaoHashMap.select_name(name);
        phoneDaoIO.select_name(name);
    }

    private static void selectAll() {
        System.out.println("----查找所有手机");
//        phoneDaoSet.selectAll();
//        phoneDaoHashMap.selectAll();
        phoneDaoIO.selectAll();
    }

    private static void delete() {
        System.out.println("----手机出库----");
        System.out.println("请输入手机型号：");
        String type=scannerString.nextLine();
        System.out.println("请输入手机名称：");
        String name=scannerString.nextLine();
//        phoneDaoSet.delete(type,name);
//        phoneDaoHashMap.delete(type,name);
        phoneDaoIO.delete(type,name);
    }
}
